<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>爬取+复制johnnys-net的Biography记录 | -q?!</title><meta name="author" content="-q,634722680@qq.com"><meta name="copyright" content="-q"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="心血来潮好在勉强成功了">
<meta property="og:type" content="article">
<meta property="og:title" content="爬取+复制johnnys-net的Biography记录">
<meta property="og:url" content="https://gitee.com/Miracle-0718/2023/05/BioGetRecord/index.html">
<meta property="og:site_name" content="-q?!">
<meta property="og:description" content="心血来潮好在勉强成功了">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png">
<meta property="article:published_time" content="2023-05-01T12:13:41.000Z">
<meta property="article:modified_time" content="2023-05-01T15:59:08.852Z">
<meta property="article:author" content="-q">
<meta property="article:tag" content="record">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png"><link rel="shortcut icon" href="/forkishi/img/%E7%8C%B4%E5%AD%90.png"><link rel="canonical" href="https://gitee.com/Miracle-0718/2023/05/BioGetRecord/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/forkishi/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/forkishi/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: false,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '爬取+复制johnnys-net的Biography记录',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-05-01 23:59:08'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="//at.alicdn.com/t/c/font_4018759_5o1ev4yt9l5.css"><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/forkishi/archives/"><div class="headline">文章</div><div class="length-num">6</div></a><a href="/forkishi/tags/"><div class="headline">标签</div><div class="length-num">6</div></a><a href="/forkishi/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/forkishi/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/forkishi/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/forkishi/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/forkishi/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-icons"></i><span> 媒体</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/forkishi/pictures/"><i class="fa-fw fa-solid fa-image"></i><span> 图库</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/forkishi/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background: linear-gradient(to right, #834d9b, #d04ed6)"><nav id="nav"><span id="blog-info"><a href="/forkishi/" title="-q?!"><span class="site-name">-q?!</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/forkishi/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/forkishi/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/forkishi/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/forkishi/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-icons"></i><span> 媒体</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/forkishi/pictures/"><i class="fa-fw fa-solid fa-image"></i><span> 图库</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/forkishi/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">爬取+复制johnnys-net的Biography记录</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="fa-fw post-meta-icon fas fa-history"></i><span class="post-meta-label">更新于</span><time datetime="2023-05-01T15:59:08.852Z" title="更新于 2023-05-01 23:59:08">2023-05-01</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/forkishi/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E6%A1%A3/">技术文档</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="爬取+复制johnnys-net的Biography记录"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p><strong>一段日记：</strong>之前无意中乱逛杰网看到这个biography页面，虽然写得好简陋但从2011年开始都有记录，作为新规来看还有很多不怎么知道的……</p>
<p>想到5&#x2F;23之后肯定要把退社人删掉，十年好歹得留下什么痕迹吧……本来想直接截图保存的但是蛮多的，心血来潮干脆把整个扒下来好了…（好吧其实只是根本不想干正事</p>
<p>最后居然折腾了一天（差不多七八个小时？），终究是我专业不精( ‘-‘ )ノ)&#96;-‘ )</p>
<p>这是一篇没有技术含量的技术文档</p>
<h1 id="数据爬取"><a href="#数据爬取" class="headerlink" title="数据爬取"></a>数据爬取</h1><p>要扒的网站在这里 <a target="_blank" rel="noopener" href="https://www.johnnys-net.jp/page?id=bio&artist=41">johnnys-net-King&amp;PrinceBiography</a></p>
<ol>
<li><p>这个网页很好爬，直接爬取整个页面提取数据就好，本人不怎么会爬虫也很快就成功</p>
</li>
<li><p>用正则提取信息，由于原信息也不是非常规整所以结果有点小问题，直接手动校对了</p>
</li>
<li><p>数据打包成json格式方面后面网页使用</p>
</li>
</ol>
<h1 id="编写网页"><a href="#编写网页" class="headerlink" title="编写网页"></a>编写网页</h1><p>就是麻烦一点，F12看网页源码直接抄</p>
<ol>
<li><p>因为不是很会写网页组件，偷懒用了js原生的<code>&lt;select&gt;</code>组件，仅仿了一下样式，还是丑了点</p>
<ul>
<li><a target="_blank" rel="noopener" href="http://www.yangbike.com/archives/98.html">select下拉框非常简单的美化</a></li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;div <span class="keyword">class</span>=<span class="string">&quot;select-year__header&quot;</span>&gt;</span><br><span class="line">		<span class="language-xml"><span class="tag">&lt;<span class="name">select</span> <span class="attr">class</span>=<span class="string">&quot;form-control  info-select&quot;</span> <span class="attr">id</span>=<span class="string">&quot;YearSelect&quot;</span>&gt;</span></span></span><br><span class="line"><span class="language-xml">			<span class="tag">&lt;<span class="name">option</span>&gt;</span>--<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span></span><br><span class="line"><span class="language-xml">		<span class="tag">&lt;/<span class="name">select</span>&gt;</span></span></span><br><span class="line">&lt;/div&gt;</span><br></pre></td></tr></table></figure>

<p>年份选项比较多所以页面加载时动态生成，用了<strong>jQuery</strong>实现：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//选择框，动态生成年份</span></span><br><span class="line"><span class="keyword">var</span> select_html = <span class="string">&#x27;&#x27;</span>;</span><br><span class="line"><span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">2011</span>; i &lt;= <span class="number">2023</span>; i++) &#123;</span><br><span class="line">	<span class="keyword">var</span> value = i.<span class="title function_">toString</span>();</span><br><span class="line">	select_html += <span class="string">&#x27;&lt;option&gt;&#x27;</span> + value + <span class="string">&#x27;&lt;/option&gt;&#x27;</span>;</span><br><span class="line">&#125;</span><br><span class="line">$(<span class="string">&#x27;#YearSelect&#x27;</span>).<span class="title function_">append</span>(select_html);</span><br></pre></td></tr></table></figure>

<p>jQuery 查了一下发现有人说百度的cdn失效了，保险起见还是官网下载到本地用， 在<code>&lt;head&gt;</code>部分引入：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;script type=<span class="string">&quot;text/javascript&quot;</span> src=<span class="string">&#x27;./jquery-3.6.4.min.js&#x27;</span>&gt;&lt;/script&gt;</span><br></pre></td></tr></table></figure>


</li>
<li><p>列表部分仿照原网页<code>&lt;ul&gt;</code>+<code>&lt;li&gt;</code>直接标签实现：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;ul <span class="keyword">class</span>=<span class="string">&quot;biography-list&quot;</span> id=<span class="string">&quot;YearList&quot;</span>&gt;</span><br><span class="line">	&lt;!-- <span class="language-xml"><span class="tag">&lt;<span class="name">li</span>&gt;</span> <span class="tag">&lt;<span class="name">strong</span>&gt;</span>1/3-<span class="tag">&lt;/<span class="name">strong</span>&gt;</span><span class="tag">&lt;<span class="name">br</span>&gt;</span> CX<span class="tag">&lt;<span class="name">br</span> /&gt;</span>｢VS魂｣<span class="tag">&lt;<span class="name">text</span> <span class="attr">style</span>=<span class="string">&quot;color: red;&quot;</span>&gt;</span>【岸優太】<span class="tag">&lt;/<span class="name">text</span>&gt;</span> <span class="tag">&lt;/<span class="name">li</span>&gt;</span> --&gt;</span></span><br><span class="line"><span class="language-xml"><span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span></span><br></pre></td></tr></table></figure>

<p>内容根据选择组件动态渲染，相应函数：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//year选择框响应函数</span></span><br><span class="line">$(<span class="string">&#x27;#YearSelect&#x27;</span>).<span class="title function_">change</span>(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">		<span class="keyword">let</span> choose_y = $(<span class="string">&#x27;#YearSelect&#x27;</span>).<span class="title function_">val</span>();</span><br><span class="line">		<span class="variable language_">console</span>.<span class="title function_">log</span>($(<span class="string">&#x27;#YearSelect&#x27;</span>).<span class="title function_">val</span>());</span><br><span class="line">		$(<span class="string">&quot;#YearList&quot;</span>).<span class="title function_">find</span>(<span class="string">&quot;li&quot;</span>).<span class="title function_">remove</span>();</span><br><span class="line">		<span class="title function_">showData</span>(y = choose_y)</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>


</li>
<li><p>json数据读取和怎么显示到页面上：</p>
<p>参考：</p>
<ul>
<li><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/Avatarhhh/article/details/105630838">JQuery 如何ul动态添加li标签</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/aLoudVoice_/article/details/105192188">新手如何使用JavaScript读取json文件</a></p>
</li>
</ul>
<p>凑出了奇怪的代码：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//获取json数据并选取特定年份展示在页面上</span></span><br><span class="line">	showData = <span class="keyword">function</span> (<span class="params">y = <span class="number">2023</span></span>) &#123;</span><br><span class="line">		$.<span class="title function_">ajax</span>(&#123;</span><br><span class="line">			<span class="attr">url</span>: <span class="string">&quot;all_list.json&quot;</span>,</span><br><span class="line">			<span class="attr">type</span>: <span class="string">&quot;GET&quot;</span>,</span><br><span class="line">			<span class="attr">dataType</span>: <span class="string">&quot;json&quot;</span>,</span><br><span class="line">			<span class="attr">success</span>:</span><br><span class="line">				<span class="keyword">function</span> (<span class="params">data</span>) &#123;</span><br><span class="line">					<span class="title function_">showList</span>(data, y = y)</span><br><span class="line">				&#125;</span><br><span class="line">		&#125;);</span><br><span class="line">	&#125;</span><br><span class="line">   </span><br><span class="line">	<span class="comment">//将某一年的数据填充到页面列表中</span></span><br><span class="line">	showList = <span class="keyword">function</span> (<span class="params">data, y</span>) &#123;</span><br><span class="line">		<span class="keyword">let</span> yid = y - <span class="number">2011</span>;</span><br><span class="line">		<span class="keyword">let</span> worklist = data[yid].<span class="property">worklist</span>;</span><br><span class="line">		<span class="comment">// console.log(worklist);</span></span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; worklist.<span class="property">length</span>; i++) &#123;</span><br><span class="line">			<span class="keyword">var</span> li_str = <span class="string">&#x27;&lt;li&gt; &lt;strong&gt;&#x27;</span>;</span><br><span class="line">			li_str += worklist[i].<span class="property">data</span>.<span class="title function_">toString</span>() + <span class="string">&#x27;&lt;/strong&gt;&#x27;</span>; <span class="comment">//日期</span></span><br><span class="line">			<span class="keyword">if</span> (worklist[i].<span class="property">type</span> != <span class="string">&quot;&quot;</span>) &#123; <span class="comment">//日程类型</span></span><br><span class="line">				li_str += <span class="string">&#x27;&lt;br&gt;&#x27;</span> + worklist[i].<span class="property">type</span>.<span class="title function_">toString</span>();</span><br><span class="line">			&#125;</span><br><span class="line">			li_str += <span class="string">&#x27;&lt;br&gt;&#x27;</span> + worklist[i].<span class="property">name</span>.<span class="title function_">toString</span>(); <span class="comment">//名称</span></span><br><span class="line">			<span class="keyword">if</span> (<span class="string">&#x27;content&#x27;</span> <span class="keyword">in</span> worklist[i]) &#123; <span class="comment">//如果还有其他内容</span></span><br><span class="line">				li_str += <span class="string">&#x27;&lt;br&gt;&#x27;</span> + worklist[i].<span class="property">content</span>.<span class="title function_">toString</span>()</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span> (<span class="string">&#x27;member&#x27;</span> <span class="keyword">in</span> worklist[i]) &#123;</span><br><span class="line">				member_arr = worklist[i].<span class="property">member</span>.<span class="title function_">map</span>(showMember)</span><br><span class="line">				li_str += <span class="string">&#x27;&lt;br&gt;&#x27;</span> + member_arr.<span class="title function_">join</span>()</span><br><span class="line">			&#125;</span><br><span class="line">			li_str += <span class="string">&#x27;&lt;/li&gt;&#x27;</span>;</span><br><span class="line">			$(<span class="string">&#x27;#YearList&#x27;</span>).<span class="title function_">append</span>(li_str);</span><br><span class="line">		&#125;</span><br><span class="line">   </span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<p>这个函数调用方式绝对很奇怪，但没事，它实现了</p>
</li>
</ol>
<h1 id="html页面嵌入Hexo的md文档"><a href="#html页面嵌入Hexo的md文档" class="headerlink" title="html页面嵌入Hexo的md文档"></a>html页面嵌入Hexo的md文档</h1><p>方法：<code>&lt;iframe&gt; </code> 标签嵌入</p>
<p>参考：</p>
<ul>
<li><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_33384402/article/details/107240192">Hexo内嵌网页踩坑记录</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://zicowarn.github.io/2020/09/02/hexo-02-embed-html-and-downloads-code/">Hexo 解决嵌入的html被渲染的问题和code_dir的配置项的用法</a></p>
</li>
</ul>
<p>主要参考第一篇，第二篇说的 <em>code_dir</em>的配置</p>
<div class="note danger simple"><p>出现问题：标签里显示路径下找不到该外部html页面</p>
</div>

<p>解决：</p>
<p>​	看了一下路径发现md页面渲染成html后，显示的路径是在 <code>/2023/05/01/页面名</code> 的文件夹下 ,</p>
<div class="note info simple"><p>文档生成的html页面和文档md文件保存路径并不一致！需要 <code>hexo g</code>生成后在<code>\public</code>文件夹下查看；或在远程仓库上也能看到最终的文件结构。</p>
</div>

<p>​	查看 <code>/_config.yml</code> 发现生成路径是由配置项<em>permalink</em>决定的，可自行修改:</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">permalink:</span> <span class="string">:year/:month/:title/</span> <span class="comment">#默认是year/:month/:day/:title/</span></span><br></pre></td></tr></table></figure>

<p>​	最终生成的文件结构如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">- public</span><br><span class="line">	- 2023</span><br><span class="line">		-05</span><br><span class="line">			- KP_biography/index.html</span><br><span class="line">        ...</span><br><span class="line">    - assets</span><br><span class="line">        - biography</span><br><span class="line">        	- ***.html</span><br><span class="line">            - ***.css</span><br><span class="line">    ...</span><br></pre></td></tr></table></figure>

<p>​	在<code>KP_biography.md</code>中引入时要准确跳到父级目录：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&lt;iframe src=<span class="string">&quot;../../../assets/biography.html&quot;</span> height=<span class="string">&quot;800px&quot;</span> width=<span class="string">&quot;100%&quot;</span> scrolling=<span class="string">&quot;auto&quot;</span> frameborder=<span class="string">&quot;0&quot;</span> style=<span class="string">&quot;box-shadow: 0px 0px 20px -10px #888;&quot;</span>&gt;</span><br><span class="line">&lt;/iframe&gt;</span><br></pre></td></tr></table></figure>

<p>参考的博客都是2020年左右写的，可能是由hexo更新带来的问题。</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://gitee.com/Miracle-0718">-q</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://gitee.com/Miracle-0718/2023/05/BioGetRecord/">https://gitee.com/Miracle-0718/2023/05/BioGetRecord/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://gitee.com/Miracle-0718" target="_blank">-q?!</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/forkishi/tags/record/">record</a></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="next-post pull-full"><a href="/forkishi/2023/05/KP-Biography/" title="King&amp;Prince Biography"><img class="cover" src="https://myli-bucket1.oss-cn-beijing.aliyuncs.com/picgo/202305020030962.GIF" onerror="onerror=null;src='/forkishi/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">King&amp;Prince Biography</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/forkishi/2023/04/start/" title="本博客搭建记录"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-04-16</div><div class="title">本博客搭建记录</div></div></a></div><div><a href="/forkishi/2023/04/%E8%87%AA%E7%86%9F%E4%B8%AD%E5%AD%97%E8%AE%B0%E5%BD%95/" title="KP相关产出的记录"><img class="cover" src="https://myli-bucket1.oss-cn-beijing.aliyuncs.com/picgo/202304161929474.png" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-05-01</div><div class="title">KP相关产出的记录</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E7%88%AC%E5%8F%96"><span class="toc-number">1.</span> <span class="toc-text">数据爬取</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%BC%96%E5%86%99%E7%BD%91%E9%A1%B5"><span class="toc-number">2.</span> <span class="toc-text">编写网页</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#html%E9%A1%B5%E9%9D%A2%E5%B5%8C%E5%85%A5Hexo%E7%9A%84md%E6%96%87%E6%A1%A3"><span class="toc-number">3.</span> <span class="toc-text">html页面嵌入Hexo的md文档</span></a></li></ol></div></div></div></div></main><footer id="footer" style="background: linear-gradient(to right, #834d9b, #d04ed6)"><div id="footer-wrap"><div class="copyright">&copy;2023 By -q</div><div class="footer_custom_text">Hi,这里都被你找到了</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/forkishi/js/utils.js"></script><script src="/forkishi/js/main.js"></script><script src="/forkishi/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>